﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LCL;
using System.Net.Sockets;
using LCL.Network;
using LCL.Network.Profinet.Melsec;
namespace LCL.Tests.Common
{
    public class NetworkDeviceBase
    {
        #region IDataTransfer Example
        public class DataMy : IDataTransfer
        {
            // 根据对应的设备选择对应的实例化
            // 三菱 RegularByteTransform
            // 西门子 ReverseBytesTransform
            // Modbus及欧姆龙 ReverseWordTransform
            private IByteTransform byteTransform = new RegularByteTransform( );
            public ushort ReadCount = 5;
            public short temperature = 0;  // 温度
            public float press = 0f;       // 压力
            public int others = 0;         // 自定义的其他信息
            public void ParseSource( byte[] Data )
            {
                temperature = byteTransform.TransInt16( Data, 0 );
                press = byteTransform.TransSingle( Data, 2 );
                others = byteTransform.TransInt32( Data, 6 );
            }
            public byte[] ToSource( )
            {
                byte[] buffer = new byte[10];
                byteTransform.TransByte( temperature ).CopyTo( buffer, 0 );
                byteTransform.TransByte( press ).CopyTo( buffer, 2 );
                byteTransform.TransByte( others ).CopyTo( buffer, 6 );
                return buffer;
            }
            ushort IDataTransfer.ReadCount
            {
                get { throw new NotImplementedException(); }
            }
        }
        #endregion
        public void ReadCustomerExample( )
        {
            #region ReadCustomerExample
            MelsecMcNet melsec = new MelsecMcNet( "192.168.0.100", 6000 );
            Result<DataMy> read = melsec.ReadCustomer<DataMy>( "M100" );
            if (read.Success)
            {
                // success
                DataMy data = read.Data;
            }
            else
            {
                // failed
                Console.WriteLine( "读取失败：" + read.Message );
            }
            #endregion
        }
        public void WriteCustomerExample( )
        {
            #region WriteCustomerExample
            MelsecMcNet melsec = new MelsecMcNet( "192.168.0.100", 6000 );
            DataMy dataMy = new DataMy( );
            dataMy.temperature = 20;
            dataMy.press = 123.456f;
            dataMy.others = 1234232132;
            Result write = melsec.WriteCustomer( "M100" ,dataMy );
            if (write.Success)
            {
                // success
                Console.WriteLine( "写入成功！" );
            }
            else
            {
                // failed
                Console.WriteLine( "读取失败：" + write.Message );
            }
            #endregion
        }
        public void ReadInt16( )
        {
            #region ReadInt16
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            short d100 = melsec_net.ReadInt16( "D100" ).Data;
            // 如果需要判断是否读取成功
            Result<short> R_d100 = melsec_net.ReadInt16( "D100" );
            if (R_d100.Success)
            {
                // success
                short value = R_d100.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }

        public void ReadInt16Array( )
        {
            #region ReadInt16Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            short[] d100_109_value = melsec_net.ReadInt16( "D100", 10 ).Data;
            // 如果需要判断是否读取成功
            Result<short[]> R_d100_109_value = melsec_net.ReadInt16( "D100", 10 );
            if (R_d100_109_value.Success)
            {
                // success
                short value_d100 = R_d100_109_value.Data[0];
                short value_d101 = R_d100_109_value.Data[1];
                short value_d102 = R_d100_109_value.Data[2];
                short value_d103 = R_d100_109_value.Data[3];
                short value_d104 = R_d100_109_value.Data[4];
                short value_d105 = R_d100_109_value.Data[5];
                short value_d106 = R_d100_109_value.Data[6];
                short value_d107 = R_d100_109_value.Data[7];
                short value_d108 = R_d100_109_value.Data[8];
                short value_d109 = R_d100_109_value.Data[9];
            }
            else
            {
                // failed
            }
            #endregion
        }

        public void ReadUInt16( )
        {
            #region ReadUInt16
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            ushort d100 = melsec_net.ReadUInt16( "D100" ).Data;
            // 如果需要判断是否读取成功
            Result<ushort> R_d100 = melsec_net.ReadUInt16( "D100" );
            if (R_d100.Success)
            {
                // success
                ushort value = R_d100.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }

        public void ReadUInt16Array( )
        {
            #region ReadUInt16Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            ushort[] d100_109 = melsec_net.ReadUInt16( "D100", 10 ).Data;
            // 如果需要判断是否读取成功
            Result<ushort[]> R_d100_109 = melsec_net.ReadUInt16( "D100", 10 );
            if (R_d100_109.Success)
            {
                // success
                ushort value_d100 = R_d100_109.Data[0];
                ushort value_d101 = R_d100_109.Data[1];
                ushort value_d102 = R_d100_109.Data[2];
                ushort value_d103 = R_d100_109.Data[3];
                ushort value_d104 = R_d100_109.Data[4];
                ushort value_d105 = R_d100_109.Data[5];
                ushort value_d106 = R_d100_109.Data[6];
                ushort value_d107 = R_d100_109.Data[7];
                ushort value_d108 = R_d100_109.Data[8];
                ushort value_d109 = R_d100_109.Data[9];
            }
            else
            {
                // failed
            }
            #endregion
        }
   
        public void ReadInt32( )
        {
            #region ReadInt32
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            int d100 = melsec_net.ReadInt32( "D100" ).Data;
            // 如果需要判断是否读取成功
            Result<int> R_d100 = melsec_net.ReadInt32( "D100" );
            if (R_d100.Success)
            {
                // success
                int value = R_d100.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }
   
        public void ReadInt32Array( )
        {
            #region ReadInt32Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            int[] d100_119 = melsec_net.ReadInt32( "D100", 10 ).Data;
            // 如果需要判断是否读取成功
            Result<int[]> R_d100_119 = melsec_net.ReadInt32( "D100", 10 );
            if (R_d100_119.Success)
            {
                // success
                int value_d100 = R_d100_119.Data[0];
                int value_d102 = R_d100_119.Data[1];
                int value_d104 = R_d100_119.Data[2];
                int value_d106 = R_d100_119.Data[3];
                int value_d108 = R_d100_119.Data[4];
                int value_d110 = R_d100_119.Data[5];
                int value_d112 = R_d100_119.Data[6];
                int value_d114 = R_d100_119.Data[7];
                int value_d116 = R_d100_119.Data[8];
                int value_d118 = R_d100_119.Data[9];
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void ReadUInt32( )
        {
            #region ReadUInt32
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            uint d100 = melsec_net.ReadUInt32( "D100" ).Data;
            // 如果需要判断是否读取成功
            Result<uint> R_d100 = melsec_net.ReadUInt32( "D100" );
            if (R_d100.Success)
            {
                // success
                uint value = R_d100.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void ReadUInt32Array( )
        {
            #region ReadUInt32Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            uint[] d100_119 = melsec_net.ReadUInt32( "D100", 10 ).Data;
            // 如果需要判断是否读取成功
            Result<uint[]> R_d100_119 = melsec_net.ReadUInt32( "D100", 10 );
            if (R_d100_119.Success)
            {
                uint value_d100 = R_d100_119.Data[0];
                uint value_d102 = R_d100_119.Data[1];
                uint value_d104 = R_d100_119.Data[2];
                uint value_d106 = R_d100_119.Data[3];
                uint value_d108 = R_d100_119.Data[4];
                uint value_d110 = R_d100_119.Data[5];
                uint value_d112 = R_d100_119.Data[6];
                uint value_d114 = R_d100_119.Data[7];
                uint value_d116 = R_d100_119.Data[8];
                uint value_d118 = R_d100_119.Data[9];
            }
            else
            {
                // failed
            }
            #endregion
        }
       
        public void ReadFloat( )
        {
            #region ReadFloat
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            float d100 = melsec_net.ReadFloat( "D100" ).Data;
            // 如果需要判断是否读取成功
            Result<float> R_d100 = melsec_net.ReadFloat( "D100" );
            if (R_d100.Success)
            {
                // success
                float value = R_d100.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }
     
        public void ReadFloatArray( )
        {
            #region ReadFloatArray
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            float[] d100_119 = melsec_net.ReadFloat( "D100", 10 ).Data;
            // 如果需要判断是否读取成功
            Result<float[]> R_d100_119 = melsec_net.ReadFloat( "D100", 10 );
            if (R_d100_119.Success)
            {
                float value_d100 = R_d100_119.Data[0];
                float value_d102 = R_d100_119.Data[1];
                float value_d104 = R_d100_119.Data[2];
                float value_d106 = R_d100_119.Data[3];
                float value_d108 = R_d100_119.Data[4];
                float value_d110 = R_d100_119.Data[5];
                float value_d112 = R_d100_119.Data[6];
                float value_d114 = R_d100_119.Data[7];
                float value_d116 = R_d100_119.Data[8];
                float value_d118 = R_d100_119.Data[9];
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void ReadInt64( )
        {
            #region ReadInt64
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            long d100 = melsec_net.ReadInt64( "D100" ).Data;
            // 如果需要判断是否读取成功
            Result<long> R_d100 = melsec_net.ReadInt64( "D100" );
            if (R_d100.Success)
            {
                // success
                double value = R_d100.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }
    
        public void ReadInt64Array( )
        {
            #region ReadInt64Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            long[] d100_139 = melsec_net.ReadInt64( "D100", 10 ).Data;
            // 如果需要判断是否读取成功
            Result<long[]> R_d100_139 = melsec_net.ReadInt64( "D100", 10 );
            if (R_d100_139.Success)
            {
                long value_d100 = R_d100_139.Data[0];
                long value_d104 = R_d100_139.Data[1];
                long value_d108 = R_d100_139.Data[2];
                long value_d112 = R_d100_139.Data[3];
                long value_d116 = R_d100_139.Data[4];
                long value_d120 = R_d100_139.Data[5];
                long value_d124 = R_d100_139.Data[6];
                long value_d128 = R_d100_139.Data[7];
                long value_d132 = R_d100_139.Data[8];
                long value_d136 = R_d100_139.Data[9];
            }
            else
            {
                // failed
            }
            #endregion
        }
    
        public void ReadUInt64( )
        {
            #region ReadUInt64
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            ulong d100 = melsec_net.ReadUInt64( "D100" ).Data;
            // 如果需要判断是否读取成功
            Result<ulong> R_d100 = melsec_net.ReadUInt64( "D100" );
            if (R_d100.Success)
            {
                // success
                double value = R_d100.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }
     
        public void ReadUInt64Array( )
        {
            #region ReadUInt64Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            ulong[] d100_139 = melsec_net.ReadUInt64( "D100", 10 ).Data;
            // 如果需要判断是否读取成功
            Result<ulong[]> R_d100_139 = melsec_net.ReadUInt64( "D100", 10 );
            if (R_d100_139.Success)
            {
                ulong value_d100 = R_d100_139.Data[0];
                ulong value_d104 = R_d100_139.Data[1];
                ulong value_d108 = R_d100_139.Data[2];
                ulong value_d112 = R_d100_139.Data[3];
                ulong value_d116 = R_d100_139.Data[4];
                ulong value_d120 = R_d100_139.Data[5];
                ulong value_d124 = R_d100_139.Data[6];
                ulong value_d128 = R_d100_139.Data[7];
                ulong value_d132 = R_d100_139.Data[8];
                ulong value_d136 = R_d100_139.Data[9];
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void ReadDouble( )
        {
            #region ReadDouble
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            double d100 = melsec_net.ReadDouble( "D100" ).Data;
            // 如果需要判断是否读取成功
            Result<double> R_d100 = melsec_net.ReadDouble( "D100" );
            if (R_d100.Success)
            {
                // success
                double value = R_d100.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }
     
        public void ReadDoubleArray( )
        {
            #region ReadDoubleArray
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            double[] d100_139 = melsec_net.ReadDouble( "D100", 10 ).Data;
            // 如果需要判断是否读取成功
            Result<double[]> R_d100_139 = melsec_net.ReadDouble( "D100", 10 );
            if (R_d100_139.Success)
            {
                double value_d100 = R_d100_139.Data[0];
                double value_d104 = R_d100_139.Data[1];
                double value_d108 = R_d100_139.Data[2];
                double value_d112 = R_d100_139.Data[3];
                double value_d116 = R_d100_139.Data[4];
                double value_d120 = R_d100_139.Data[5];
                double value_d124 = R_d100_139.Data[6];
                double value_d128 = R_d100_139.Data[7];
                double value_d132 = R_d100_139.Data[8];
                double value_d136 = R_d100_139.Data[9];
            }
            else
            {
                // failed
            }
            #endregion
        }
       
        public void ReadString( )
        {
            #region ReadString
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 以下是简单的读取，没有仔细校验的方式
            string d100_value = melsec_net.ReadString( "D100", 5 ).Data;
            // 如果需要判断是否读取成功
            Result<string> R_d100_value = melsec_net.ReadString( "D100", 5 );
            if (R_d100_value.Success)
            {
                // success
                string value = R_d100_value.Data;
            }
            else
            {
                // failed
            }
            #endregion
        }
     
       
        public void WriteInt16( )
        {
            #region WriteInt16
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", (short)123 );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", (short)123 );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
    
        public void WriteInt16Array( )
        {
            #region WriteInt16Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", new short[] { 123, -342, 3535 } );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", new short[] { 123, -342, 3535 } );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteUInt16( )
        {
            #region WriteUInt16
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", (ushort)123 );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", (ushort)123 );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteUInt16Array( )
        {
            #region WriteUInt16Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", new ushort[] { 123, 342, 3535 } );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", new ushort[] { 123, 342, 3535 } );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteInt32( )
        {
            #region WriteInt32
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", 123 );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", 123 );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
     
        public void WriteInt32Array( )
        {
            #region WriteInt32Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", new int[] { 123, 342, -3535, 1235234 } );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", new int[] { 123, 342, -3535, 1235234 } );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteUInt32( )
        {
            #region WriteUInt32
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", (uint)123 );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", (uint)123 );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteUInt32Array( )
        {
            #region WriteUInt32Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", new uint[] { 123, 342, 3535, 1235234 } );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", new uint[] { 123, 342, 3535, 1235234 } );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteFloat( )
        {
            #region WriteFloat
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", 123.456f );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", 123.456f );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
       
        public void WriteFloatArray( )
        {
            #region WriteFloatArray
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", new float[] { 123f, 342.23f, 0.001f, -123.34f } );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", new float[] { 123f, 342.23f, 0.001f, -123.34f } );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteInt64( )
        {
            #region WriteInt64
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", 12334242354L );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", 12334242354L );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
     
        public void WriteInt64Array( )
        {
            #region WriteInt64Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", new long[] { 123, 342, -352312335, 1235234 } );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", new long[] { 123, 342, -352312335, 1235234 } );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
     
        public void WriteUInt64( )
        {
            #region WriteUInt64
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", 12334242354UL );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", 12334242354UL );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteUInt64Array( )
        {
            #region WriteUInt64Array
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", new ulong[] { 123, 342, 352312335, 1235234 } );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", new ulong[] { 123, 342, 352312335, 1235234 } );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteDouble( )
        {
            #region WriteDouble
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", 123.456d );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", 123.456d );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
     
        public void WriteDoubleArray( )
        {
            #region WriteDoubleArray
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", new double[] { 123d, 342.23d, 0.001d, -123.34d } );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", new double[] { 123d, 342.23d, 0.001d, -123.34d } );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
       
        public void WriteString( )
        {
            #region WriteString
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", "ABCDEFGH" );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", "ABCDEFGH" );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
        public void WriteString2( )
        {
            #region WriteString2
            MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );
            // 简单的写入
            melsec_net.Write( "D100", "ABCDEFGH", 10 );
            // 如果想要判断是否写入成功
            Result write = melsec_net.Write( "D100", "ABCDEFGH", 10 );
            if (write.Success)
            {
                // success
            }
            else
            {
                // failed
            }
            #endregion
        }
      
    }
}
